<div class="page-header">
    <h1>
        渠道管理
        <small>
            <i class="ace-icon fa fa-angle-double-right"></i>
            查看渠道的信息；
        </small>
    </h1>
</div>
<div class="row">
    <div class="col-xs-12">
        <table id="dtpList" class="dataTable">
            <!--<tfoot>-->
            <!--<tr>-->
            <!--<td colspan="6">本页合计：</td>-->
            <!--<td>-->
            <!--<ins id="Total_Balance">￥13645.00</ins>-->
            <!--</td>-->
            <!--<td>-->
            <!--<ins id="Total_Consumption_Amt">￥13645.00</ins>-->
            <!--</td>-->
            <!--<td colspan="2"></td>-->
            <!--</tr>-->
            <!--</tfoot>-->
        </table>
        <div id="dtpList_filter" class="dataTables_filter">
            <div>
                <label>时间：</label>
                <input id="dtpList_F_StartDate" type="text" style="width: 76px;" placeholder="开始时间">
                <label>-</label>
                <input id="dtpList_F_EndDate" type="text" style="width: 76px;" placeholder="结束时间">
                <button id="dtpList_F_Btn"></button>
            </div>
        </div>
    </div>
</div>
<script src="<%- Virtual_Path.Static %>jquery.plugin/dataTables/jquery.dataTables.min.js"></script>
<script src="<%- Virtual_Path.Static %>jquery.plugin/dataTables/jquery.dataTables.bootstrap.min.js"></script>
<script>
    $(function () {
        //////////////////////////////////////////////////////////
        //时间输入框插件
        //////////////////////////////////////////////////////////
        $('#dtpList_F_StartDate , #dtpList_F_EndDate').datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            minView: 2,
            autoclose: true
        });
        //////////////////////////////////////////////////////////
        //绑定日期选择框
        //////////////////////////////////////////////////////////
        $.KOC.Date.Select.Bind({
            eSelect: $('#dtpList_F_SelectDate'),
            eBegin: $('#dtpList_F_StartDate'),
            eEnd: $('#dtpList_F_EndDate')
        });
        //列表数据(分页)
        var _dtpList = $("#dtpList").dataTable({
            //列信息
            'aoColumns': [
                {
                    'sWidth': '30px', 'data': 'Report_Day', 'sTitle': '日期', 'bSortable': false, 'sClass': 'center',
                },
                {
                    'sWidth': '30px', 'data': 'Channel_ID', 'sTitle': '渠道ID', 'sClass': 'center',
                },
                {
                    'sWidth': '30px', 'data': 'Channel_Name', 'sTitle': '渠道名称', 'bSortable': false, 'sClass': 'center',
                },
                {
                    "sWidth": "30px", 'data': 'Channel_ID', "sTitle": "渠道注册总人数", "sClass": "center", 'bSortable': false,
                    "createdCell": function (td, cellData, rowData) {
                        _.forEach(_PageData.data, function (ThisValue) {
                           if(cellData==ThisValue.Channel_ID){
                               $(td).html(ThisValue.Total_Count_SignUp);
                           }
                        });
                    }
                },
                {
                    "sWidth": "30px", 'data': 'Channel_ID', "sTitle": "注册活跃率", "sClass": "center", 'bSortable': false,
                    "createdCell": function (td, cellData, rowData) {
                        _.forEach(_PageData.data, function (ThisValue) {
                            if(cellData==ThisValue.Channel_ID){
                                $(td).html((rowData.User_Count_SignIn+rowData.User_Count_SignUp)/ThisValue.Total_Count_SignUp);
                            }
                        });
                    }
                },
                {
                    'sWidth': '30px', 'data': 'Recharge_User', 'sTitle': '充值人数', 'bSortable': false, 'sClass': 'center',
                },
                {
                    "sWidth": "30px", 'data': 'Channel_ID', "sTitle": "付费率", "sClass": "center", 'bSortable': false,
                    "createdCell": function (td, cellData, rowData) {
                        _.forEach(_PageData.data, function (ThisValue) {
                            if(cellData==ThisValue.Channel_ID){
                                $(td).html(rowData.Recharge_User/ThisValue.User_Count_SignUp);
                            }
                        });
                    }
                },
                {
                    'sWidth': '30px', 'data': 'Recharge_Count', 'sTitle': '充值次数', 'bSortable': false, 'sClass': 'center',
                },
                {
                    'sWidth': '30px', 'data': 'Recharge_Money', 'sTitle': '充值金额',  'sClass': 'center',
                },
                {
                    'sWidth': '30px', 'data': 'Recharge_Coin', 'sTitle': '充值金币',  'sClass': 'center',
                },
                {
                    'sWidth': '30px', 'data': 'Recharge_Poundage', 'sTitle': '充值手续费',  'sClass': 'center',
                },
                {
                    'sWidth': '30px', 'data': 'User_Count_SignUp', 'sTitle': '当天注册人数',  'sClass': 'center',
                },
                {
                    'sWidth': '30px', 'data': 'User_Count_SignIn', 'sTitle': '当天登录人数',  'sClass': 'center',
                }
//                {
//                    "sWidth": "30px", 'data': 'Channel_ID', "sTitle": "操作", "sClass": "center", 'bSortable': false,
//                    "createdCell": function (td, cellData, rowData) {
//                        $(td).html('<button type="button" name="itemChannelInfo" RightCode="{Statistics}[Channel](Info)" class="btn btn-white btn-minier btn-info"><i class="fa fa-eye"></i> 明细</button>');
//                    }
//                }
            ],
            'aaSorting': [0, 'desc'],
            'sAjaxSource': '/ajax/user.statistics-info.channel-day-statistics.page',
            'fnServerParams': function (aoData) {
                if (!this.arrPageFilter) {
                    //搜索:条件发生变化
                    this.arrPageFilter = [];
                    this.arrPageFilter.push(
                            {'name': 'F_StartDate', 'value': $(this.selector + '_F_StartDate').val()},
                            {'name': 'F_EndDate', 'value': $(this.selector + '_F_EndDate').val()}
                    );
                }
                else {
                    //重置条件框内容：未按搜索按钮
                    $(this.selector + '_F_StartDate').val(this.arrPageFilter[0].value);
                    $(this.selector + '_F_EndDate').val(this.arrPageFilter[1].value);
                }
                this.ofnServerParams(aoData);
            }
        }).on('click', 'tbody button[name="itemChannelInfo"]', function () {
            var _rowData = _dtpList.fnGetData($(this).closest('tr'));
            $.CommonAdmin.OpenWindow(':StatisticsChannelInfo:' + _rowData.Channel_ID);
        });
    });
</script>